# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: team/kde <bribbers@disroot.org>

# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=kde-applications
pkgname=kdeconnect
pkgver=23.08.4
pkgrel=0
pkgdesc="Adds communication between KDE and your smartphone"
url="https://community.kde.org/KDEConnect"
# armhf blocked by extra-cmake-modules
arch="all !armhf"
license="GPL-2.0-only OR GPL-3.0-only"
depends="
	kirigami2
	qt5-qtquickcontrols
	sshfs
	"
makedepends="
	extra-cmake-modules
	kcmutils5-dev
	kconfigwidgets5-dev
	kdbusaddons5-dev
	kdoctools5-dev
	ki18n5-dev
	kiconthemes5-dev
	kio5-dev
	kirigami2-dev
	knotifications5-dev
	kpeople5-dev
	kpeoplevcard-dev
	kservice5-dev
	kwayland5-dev
	libfakekey-dev
	modemmanager-qt5-dev
	pulseaudio-qt-dev
	qca-dev
	qqc2-desktop-style5-dev
	qt5-qtbase-dev
	qt5-qtmultimedia-dev
	samurai
	"
checkdepends="xvfb-run"
subpackages="$pkgname-doc $pkgname-lang $pkgname-nftables"
_repo_url="https://invent.kde.org/network/kdeconnect-kde.git"
source="https://download.kde.org/stable/release-service/$pkgver/src/kdeconnect-kde-$pkgver.tar.xz
	60_kdeconnect.nft
	"
builddir="$srcdir/$pkgname-kde-$pkgver"

# secfixes:
#   20.08.2-r0:
#     - CVE-2020-26164

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_INSTALL_LIBEXECDIR=lib
	cmake --build build
}

check() {
	cd build
	# testsslsocketlinereader, testnotificationlistener and sendfiletest are broken
	CTEST_OUTPUT_ON_FAILURE=TRUE xvfb-run ctest -E "testsslsocketlinereader|testnotificationlistener|sendfiletest"
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

nftables() {
	pkgdesc="$pkgdesc (nftables rules)"
	install_if="$pkgname=$pkgver-r$pkgrel nftables"

	install -Dm644 -t "$subpkgdir"/etc/nftables.d "$srcdir"/60_kdeconnect.nft
}

sha512sums="
4cdeabf17ea6dba002d801de5fee858bb757620a1aabc05eb171a36c3fe2a08f47ca80b4854025701114340d496218544fe7b964910a7e6e39a66cda4242e75e  kdeconnect-kde-23.08.4.tar.xz
0ccc2cb0ffd3892698b45bcf723cfdd23ad98f0e2b0436cd0a91d9ed13c6992853e2c4092ee8a0edc6216f1f262151e99e344b8f16c52237e9ff8de62fd37cae  60_kdeconnect.nft
"
